package lumis.service.portalmanagement.file;

import java.util.Locale;

import lumis.doui.processaction.ProcessActionHandler;
import lumis.doui.source.Source;
import lumis.portal.PortalException;
import lumis.portal.manager.ManagerFactory;
import lumis.util.PortalUtil;

/**
 * Class responsible for update metadata of files in lum_File.
 * 
 * @version $Revision: 13092 $ $Date: 2011-05-28 18:19:06 -0300 (Sat, 28 May 2011) $
 * @since 6.0.0
 */
public class UpdateMetadataProcessActionHandler extends ProcessActionHandler<Source>
{

	/**
	 * Starts the thread that will updates the metadata of all files.
	 * 
	 * @version $Revision: 13092 $ $Date: 2011-05-28 18:19:06 -0300 (Sat, 28 May 2011) $
	 * @since 6.0.0
	 */
	public void processAction() throws PortalException
	{
		String processId = PortalUtil.generateNewGuid();
		setParameter("processId", processId);
		beginUpdateMetadata(sessionConfig.getUserId(), sessionConfig.getLocale(), processId);
		addDefaultResponse();
	}

	private void beginUpdateMetadata(String userId, Locale locale, String processId)
	{
		ManagerFactory.getExecutorManager().submit(new UpdateMetadataRunner(userId, locale, processId));
	}

}
